package moni.anyou.com.view.view;

import android.app.AlertDialog;
import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import moni.anyou.com.view.R;


/**
 * Created by Lin on 16/8/29.
 */

public class ConfirmDialog extends AlertDialog {

    TextView title;
    TextView content;
    ImageView line3;
    TextView tvCheck;
    TextView tvCancel;
    TextView tvSubmit;
    ImageView icon;
    RelativeLayout rlCheck;
    View background;

    public ConfirmDialog(@NonNull Context context) {
        super(context,R.style.versionDialog);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        show();
        setContentView(R.layout.dialog_confirm);
        title=(TextView) findViewById(R.id.title);
        content=(TextView) findViewById(R.id.content);
        line3=(ImageView) findViewById(R.id.line3);
        tvCheck=(TextView)findViewById(R.id.tv_check);
        tvCancel=(TextView)findViewById(R.id.tv_cancel);
        tvSubmit=(TextView) findViewById(R.id.tv_submit);
        rlCheck=(RelativeLayout)findViewById(R.id.rl_check);
        background=findViewById(R.id.background);
        icon= (ImageView) findViewById(R.id.icon);
        this.setCanceledOnTouchOutside(true);
    }

    public TextView getTitle() {
        return title;
    }

    public ConfirmDialog setTitle(TextView title) {
        this.title = title;
        title.setVisibility(View.VISIBLE);
        return this;
    }

    public ImageView getLine3() {
        return line3;
    }

    public ConfirmDialog setLine3(ImageView line3) {
        this.line3 = line3;
        return this;
    }

    public TextView getTvCheck() {
        return tvCheck;
    }


    public TextView getTvCancel() {
        return tvCancel;
    }

    public ConfirmDialog setTvCancel(TextView tvCancel) {
        this.tvCancel = tvCancel;
        return this;
    }

    public RelativeLayout getRlCheck() {
        return rlCheck;
    }

    public ConfirmDialog setRlCheck(RelativeLayout rlCheck) {
        this.rlCheck = rlCheck;
        return this;
    }


    public void setTitle(String str) {
        title.setText(str);
    }
    public void setContent(String str) {
        content.setText(str);
    }
    public void setCancelText(String str) {
        line3.setVisibility(View.VISIBLE);
        tvCancel.setVisibility(View.VISIBLE);
        tvCancel.setText(str);
    }
    public void setSubmitText(String str) {
        line3.setVisibility(View.VISIBLE);
        tvSubmit.setVisibility(View.VISIBLE);
        tvSubmit.setText(str);
    }
    public void setBackgroundClick(View.OnClickListener click)
    {
        background.setOnClickListener(click);
    }
    public void setCancelClick(View.OnClickListener click)
    {
        tvCancel.setOnClickListener(click);
    }
    public void setSubmitClick(View.OnClickListener click)
    {
        tvSubmit.setOnClickListener(click);
    }
    public void setCheckText(String str) {
        line3.setVisibility(View.INVISIBLE);
        tvCheck.setVisibility(View.VISIBLE);
        tvCheck.setText(str);
    }

    public void setCheckClick(View.OnClickListener checkClick) {
        tvCheck.setOnClickListener(checkClick);
    }


    public void setIcon(int res) {
        this.icon.setBackgroundResource(res);
        this.icon.setVisibility(View.VISIBLE);
    }
}

